﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>

<script type="text/javascript">
    var userTreeSetting = {
        check: {
            enable: true,
            chkStyle: "checkbox",
            chkboxType: { "Y": "s", "N": "s" }
        },
        callback: {
            onCheck: null,
            onRightClick: null,
            onClick: null
        }
    };

    $(function() {
        intityUserTree();
    });

    function intityUserTree() {
        $.ajax({
            url: "/Common/getUserTreeByDept",
            type: "POST",
            data: { nocheck: "false" },
            success: function(nodes) {
                userTreeSetting.callback.onClick = onUserTreeClick;
                var treeObj = $.fn.zTree.init($("#treeDemo_wfstart"), userTreeSetting, eval(nodes));
            }
        })
    }

    function onUserTreeClick(event, treeId, treeNode) {
        // alert(treeNode.tId + ", " + treeNode.name + " , " + treeNode.id + " , " + treeNode.tag);

        var treeObj = $.fn.zTree.getZTreeObj("treeDemo_wfstart");
        var nodes = treeObj.getCheckedNodes(true);

        var tempnames = "";
        var tempvalues = "";
        for (i = 0; i < nodes.length; i++) {
            tempnames += nodes[i].name + ",";
            tempvalues += nodes[i].id + ",";
        }

        $("#usertree #selectnames").attr("value", tempnames);
        $("#usertree #selectvalues").attr("value", tempvalues);

    };
</script>

<div id="usertree">
    <div>
        <input type="hidden" id="selectnames" />
        <input type="hidden" id="selectvalues" />
    </div>
    <div id="div_tree" class="ztreeDemo_wfstartBackground left" style="float: left; height: 240px;">
        <ul id="treeDemo_wfstart" class="ztree" style="height: 230px; width: 260px; float: left;">
        </ul>
    </div>
</div>
